<?php
 /**
 * @Author: kendy
 * @Date:   2019-11-04 10:00:00
 * @Last Modified by:   jiayanting
 * @Last Modified time: 2020-03-26 15:42:20
 */
function apiReturn($code='-1',$msg,$data=[]){
        $code = (string)$code;
        if($code == '-1'){
            exit('参数调用错误');
        }
        if(empty($data)){
            exit(json_encode(array('code'=>$code,'msg'=>$msg,'data'=>$data)));
        }else{
            exit(json_encode(array('code'=>$code,'msg'=>$msg,'data'=>$data)));
        }
 }

 
/**
 * [diffBetweenTwoDays 求两个日期之间相差的天数]
 * @Author   kendy
 * @DateTime 2019-11-07T16:31:46+0800
 * @param    [type]                   $day1 [description]
 * @param    [type]                   $day2 [description]
 * @return   [type]                         [description]
 */ 
function  diffBetweenTwoDays($day1,$day2){
	$sone = strtotime($day1);
	$stwo = strtotime($day2);
	if($sone < $stwo)
	{
		$tmp = $stwo;
		$stwo = $sone;
		$sone = $tmp;
	}
	return ($sone - $stwo) / 86400;
}

 function getNextMothLastDay()
{
	$first_day=date('Y-m-01',time());
    return  date('Y-m-d',strtotime("$first_day +2 month -1 day"));
}

	/**
	 * [getcommissionFee 计算产品佣金]
	 * @Author   kendy
	 * @DateTime 2019-12-27T15:17:09+0800
	 * @param    [type]                   $proPrice       [产品的总价格 价格 * 数量]
	 * @param    [type]                   $commissionRate [商家佣金比列]
	 * @return   [type]                                   []
	 */
	   function getcommissionFee($proPrice,$commissionRate){

	    return 	round($proPrice*$commissionRate/100,2);

	  }

      function numberToChinese($number)
      {
      	$number = intval($number);
	    $bit = array("精选跟团", "一", "多");
	    //各位数
	    if ($number <= 10) {
	        return $bit[$number];
	    } 
      }